#pragma once

#include <QWidget>
#include <QVector>
#include <QJsonArray>

#include <QJsonValue>
#include <QJsonObject>

class QListWidget;
class QAbstractItemDelegate;
class KeySearchWidget;
class KeySearchResultDlg : public QWidget
{
	Q_OBJECT
public:
	KeySearchResultDlg(KeySearchWidget* parent);

	void setListItemDelegate(QAbstractItemDelegate* itemDelegate);
	void setMaxHeight(int h);
	void setWidth(int w);

public slots:
	void onResultReached(QJsonArray data);

protected:
	void paintEvent(QPaintEvent* event) override;

	void showEvent(QShowEvent *event) override;
    void hideEvent(QHideEvent *event) override;
	bool eventFilter(QObject *watched, QEvent *event);

private:
	void selectNextItem(int index = -1);
	void selectPreviousItem(int index);

private:
	KeySearchWidget* m_host = nullptr;
	QListWidget* m_list;
	QVector<int>	m_columnWidths;
};